#!/usr/bin/env python
# -*- coding=utf-8 -*-

from selenium import webdriver
import time

protocol = 'https://'
utm_source_parame = 'utm_source='
utm_source_value = 'qa_test2_'

urls=[
    'www.huoban.com/__pricing.html?',
    'www.huoban.com/links.html?',
    'www.huoban.com/about.html?',
    'www.huoban.com/market/industry/2?',
    'www.huoban.com/business.html?',
    'www.huoban.com/market/subjects?',
    'www.huoban.com/market/package/795?',
    'www.huoban.com/contactus.html?',
    'www.huoban.com/market/function/8?',
    'www.huoban.com/treaty.html?',
    'www.huoban.com/feature.html?',
    'www.huoban.com/pricing-comparison.html?',
    'www.huoban.com/wxwork-event.html?',
    'www.huoban.com/index.html?',
    'www.huoban.com/pricing.html?',
    'www.huoban.com/wxwork.html?',
    'www.huoban.com/job.html?',
    'www.huoban.com/product.html?',
    'www.huoban.com/yunbiaoge.html?',
    'www.huoban.com/scene?',
    'www.huoban.com/scene/category/5000000000000537?',
    'www.huoban.com/scene/257?',
    'help.huoban.com/1?page_id=22&',
    'bbs.huoban.com/portal.php?',
    'bbs.huoban.com/forum.php?mod=viewthread&tid=4067&',
    'bbs.huoban.com/forum.php?mod=forumdisplay&fid=37&',
    'bbs.huoban.com/forum.php?mod=viewthread&tid=3304&extra=page%3D1&',
    ]



driver = webdriver.Chrome()    # Chrome浏览器
i = 0
for url in urls:
    try:
        driver.get(protocol+url+utm_source_parame+utm_source_value+str(i))
        time.sleep(5)
        
        if driver.get_cookie('uuid'):
            print('uuid:'+driver.get_cookie('uuid')['value'])
            #driver.delete_cookie('uuid')
        else:
            print('没有uuid')
        if driver.get_cookie('utm_source'):
            utm = driver.get_cookie('utm_source')['value']             
        else:
            utm = ''
        if utm == utm_source_value + str(i):
            print( url + '测试通过')
        else:
            print( url + 'XXXXXXXX 失败')

        i = i + 1
    except Execption as e:
        print("发生错误",format(e))

driver.quit()
